package com.lsmo.android.carfans.process.car;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.lsmo.android.carfans.activity.car.BrandParser;
import com.lsmo.android.carfans.model.car.Brand;
import com.lsmo.android.common.base.BaseProcess;
import com.lsmo.android.util.json.JSONException;
import com.lsmo.android.util.json.JSONUtils;

public class CarProcess extends BaseProcess{
	ArrayList<Brand> BrandList;
	private String[] strs;
	public String[] mStrings;
	public List mLists;
	
	public CarProcess() {
		// TODO Auto-generated constructor stub
	}
	
	
	/**
	 * 获取车型数据
	 */
	public ArrayList<Brand> downloadData(String str,String params)
	{
		try {
			BrandList =new BrandParser(str).Paser2Object();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BrandList;
	}
	
    /**
     * 将json转换成String[]
     * @return
     */
    public String[] getStrings(String str,String params){
    	mLists = new ArrayList<Map<String, Object>>();
    		//获取数据源
			try {
				List<Map> list = (ArrayList<Map>)JSONUtils.deserialize(str);
				for(Map mapList:list){
					String firstLetter = mapList.get("FirstLetter")==null?"":mapList.get("FirstLetter").toString();//首字母
					mLists.add(firstLetter.toUpperCase());
				}
			} catch (JSONException e) {
				e.printStackTrace();
			}
		mStrings = new String[mLists.size()];
		for(int i= 0;i<mLists.size();i++){ 
			  mStrings[i] = mLists.get(i).toString();
		}
		return mStrings;
    }
}
